package com.github.binarywang.demo.wx.mp.service;

import com.github.binarywang.demo.wx.mp.builder.MessageDTO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>  </p>
 *
 * @author Dap
 * @date 2023/5/22
 * @since 1.0
 */
@Service
public class CacheService {

    @Cacheable(cacheNames = "gpt:msgContext", key = "#fromUser", cacheManager = "cacheManagerCustomer")
    public List<MessageDTO> start(String fromUser) {
        return new ArrayList<>();
    }
    @CacheEvict(cacheNames = "gpt:msgContext", key = "#fromUser", cacheManager = "cacheManagerCustomer")
    public void clear(String fromUser) {
    }
    @Cacheable(cacheNames = "gpt:msgContext", key = "#fromUser",unless = "#result == null ", cacheManager = "cacheManagerCustomer")
    public List<MessageDTO> getContextMessage(String fromUser) {
        return null;
    }
    @CachePut(cacheNames = "gpt:msgContext", key = "#fromUser", cacheManager = "cacheManagerCustomer")
    public List<MessageDTO> put(String fromUser, List<MessageDTO> messages) {
        return messages;
    }

    @Cacheable(cacheNames = "wx:msgCache#5", key = "#msgId",unless = "#result == null ", cacheManager = "cacheManagerCustomer")
    public String msgCache(Long msgId) {
        return null;
    }

    @Cacheable(cacheNames = "wx:msgCache#5", key = "#msgId", cacheManager = "cacheManagerCustomer")
    public String msgRead(Long msgId) {
        return null;
    }
    @CachePut(cacheNames = "wx:msgCache#5", key = "#msgId", cacheManager = "cacheManagerCustomer")
    public String msgPut(Long msgId, String message) {
        return message;
    }
}
